import {
  request2
} from "../../utils/request2";

// pages/register/index.js
Page({
  onLoad: function (options) {
    // const app=getApp();
    // this.data.mobileNo=app.data.globalData.phone;
    var persInfo = wx.getStorageSync('persInfo');
    // console.log(persInfo);
    // var mobileNo=wx.getStorageSync('mobileNo');
    this.setData({
   
      username: persInfo.username,
      roleId: persInfo.roleId,
      mobilePhone: persInfo.mobilePhone,
      name: persInfo.name,
      employeeNo: persInfo.employeeNo,
    });
  },
  data: {
    
    passwd: "",
    
    passwdVaild: false,
    
    passwdRepeat: "",

    username: "",
    roleId: "",
    mobilePhone: "",
    name: "",
    employeeNo: "",

    codeStatus: {
      'ok': ' 校验成功',
      // 'empty': '未生成验证码',
      'number_error': '手机号码不一致',
      // 'code_error': '验证码不一致',
      // ' code_expired': '验证码已过期'
    },
  },

  confirmLogOut: function () {

    const personInfo = wx.getStorageSync('persInfo');
    wx.showModal({
      title: '提示',
      content: '确认切换账户吗？（将会清除缓存）',
      success: function (res) {
        if (res.confirm) {
          // console.log('用户点击确定');
          wx.clearStorageSync();
          
          
          request2({
              url: "/wx/home/logout",
              data: {
                username: personInfo.username,
                sid: personInfo.sid
              }
            })
            .then(res => {
              // console.log(res);

            })
          // .catch(err=>{
          //   wx-wx.showModal({
          //     content: '退出登录失败！',
          //     editable: false,
          //     showCancel: true,
          //     title: '提示',
          //   })
          // })
          wx.navigateTo({
            url: '/pages/login/index',
          });

          // ({
          //   url: '/pages/login/login',
          // })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

  async chanegPasswordBtn(e) {
    wx - wx.navigateTo({
      url: '/pages/changePassword/index'
    })
  }


})